package com.itboye.ihomebank.adapter;

import android.content.Context;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.bean.KaiSuoJiLu;
import com.itboye.ihomebank.bean.KaiSuoJiLuTwo;
import com.itboye.ihomebank.support.commonadapter.MutiplyCommonAdapter;
import com.itboye.ihomebank.support.commonadapter.ViewHolder;
import com.itboye.ihomebank.util.TimesUtils;

import java.util.List;

/**
 * 开锁记录
 *
 */
public class KaiSuoJiLuAdapter extends MutiplyCommonAdapter<KaiSuoJiLuTwo.KaiSuoJiLuTwoList>{
	int position;
	List<KaiSuoJiLuTwo.KaiSuoJiLuTwoList> datas;

	public KaiSuoJiLuAdapter(Context context, List<KaiSuoJiLuTwo.KaiSuoJiLuTwoList> datas,
			int... layoutId) {
		super(context, datas, layoutId);
		this.datas=datas;
	}

	@Override
	public int getItemViewType(int position) {
		return 0;
	}

	@Override
	public void getItemPosition(int position) {
		this.position=position;
		
	}

	@Override
	public void convert(ViewHolder holder, KaiSuoJiLuTwo.KaiSuoJiLuTwoList t, int type,
			int position) {
		//1-密码,2-IC卡,3-蓝牙,4-临时密码,其他-未知
		int recordtype=Integer.parseInt(t.getType().trim());
		switch (recordtype){
			case 7:
				holder.setText(R.id.jilu_phone, t.getNickname()+"(IC卡开锁)");
				break;
			case 1:
				holder.setText(R.id.jilu_phone, t.getNickname()+"(App开锁:"+t.getTempPass()+")");
				break;
			case 4:
				holder.setText(R.id.jilu_phone, t.getPwdPosition()+"(键盘密码开门:"+t.getTempPass()+")");
				break;
			default:
				holder.setText(R.id.jilu_phone, t.getNickname()+"(其他方式开门)");
				break;
		}
		holder.setText(R.id.jilu_name, t.getLock_id());
		String time= TimesUtils.timeStamp2Date(Long.parseLong(t.getOp_time()));
		holder.setText(R.id.jilu_time, time);
		if (t.getResult().equals("1")){
			holder.setText(R.id.jilu_type, "成功");
		}else{
			holder.setText(R.id.jilu_type, "失败");
		}
	}

}
